# def func(line_list):
#     leng = len(line_list)
#     for i in range(0, leng - 1, 2):
#         num1 = int(line_list[i])
#         num2 = int(line_list[i + 1])
#         print('%s + %s = %s' % (num1, num2, num1 + num2))
#
#
# if __name__ == '__main__':
#     line = input('输入数字并以空格分开：').strip()
#     line_list = line.split(' ')
#     func(line_list)

# list = []
#
#
# def func(money, coin=64):
#     number = int(money / coin)
#     money -= (number * coin)
#     coin /= 4
#     if coin < 1:
#         list.append(number)
#         return
#     func(money, coin)
#     list.append(number)
#
#
# if __name__ == '__main__':
#     price = input().strip()
#     price = int(price)
#     money = 1024 - price
#     func(money)
#     s=0
#     for i in list:
#         m = int(i)
#         s+=m
#     print(s)


import sys

if __name__ == '__main__':
    list = []
    n = int(sys.stdin.readline().strip())
    for i in range(n):
        # 读取每一行
        line = sys.stdin.readline().strip()
        list.append(line)

    for i in list:
        list1 = []
        for j in i:
            list1.append(j)
        for k in range(len(list1)):
            if list1[k] == list1[k + 1] and list1[k + 2] == list1[k + 3]:
                list1.pop(k + 2)
                break
        for m in range(len(list1)):
            if list1[m] == list1[m - 1] and list1[m] == list1[m + 1]:
                del list1[m]
        print(''.join(list1))
